package com.example.qihuibao.network

import com.example.qihuibao.bean.ReqBean
import okhttp3.RequestBody
import okhttp3.ResponseBody
import retrofit2.Call
import retrofit2.http.*
import java.util.*


/**
 *     author : cwwei
 *     e-mail : 494545699@qq.com
 *     date   : 2022/08/18
 *     desc   : api
 */
interface RetrofitApi {
    /**
     * post请求，参数为json格式
     */
    @POST
    fun postJson(
//        @Header("my_token") token: String,  //todo: token可能需要根据后端提供的接口修改
        @Url url: String,
        @Body body: RequestBody
    ) : Call<ResponseBody>?

    /**
     * post请求，参数为表单格式
     */
    @POST
    @FormUrlEncoded
    @Headers("Content-Type: application/x-www-form-urlencoded")
    fun postForm(
//        @Header("marketing-token") token: String,  //todo: token可能需要根据后端提供的接口修改
        @Url url: String,
        @FieldMap form: SortedMap<String, Any>
    ) : Call<ResponseBody>?

//    @GET("/source/common/access-control/access")
//    fun getFaceAuthResult(
//        @Query("aliUserid") aliUserid: String,
//        @Query("faceId") faceId: String,
//        @Query("sn") sn: String
//    ): Call<LoginResponseBean>?

//    @GET("/source/common/access-control/access")
//    fun getUserFaces(@Query("sn") sn: String): Call<SynchronizeFaceResponseBean>?

    /**
     * post请求，参数为json格式
     * 增加了header：app-code,timestamp
     */
//    @POST
//    fun postJson2(
//        @Header("app-code") appCode: String,
//        @Header("timestamp") timestamp: String,
//        @Url url: String,
//        @Body body: RequestBody
//    ) : Call<ResponseBody>?

//    @GET("/source/auth/eg-access/guard-sn")
//    fun getDeviceInfo(
//        @Header("app-code") appCode: String,
//        @Header("timestamp") timestamp: String,
//        @Query("sn") sn: String
//    ): Call<BaseResponseBean>?

    /**
     * 下载文件
     */
    @Streaming
    @GET
    suspend fun downloadFile(@Url fileUrl: String): ResponseBody

    @Streaming
    @GET
    fun downLoad(@Url url: String?): Call<ResponseBody>?

    @GET
    fun getRequest(
        @Url url:String
    ): Call<ResponseBody>?

    @Headers("Content-Type:application/json; charset=UTF-8")
    @POST("/ykt.flowc?flowActionName=decrypt")
    fun post(@Body body: ReqBean) : Call<ResponseBody>?

}